//
//  IllustrationController.m
//  Hai
//
//  Created by wangzijian on 16/6/13.
//  Copyright (c) 2016年 wangzijian. All rights reserved.
//

#import "BYRecordController.h"
#import "RegisterController.h"
#import "JTMaterialSwitch.h"
#import "HeatPickViewController.h"
@interface BYRecordController ()

@end

@implementation BYRecordController{
     NSInteger _buttonIndex;
    JTMaterialSwitch *_ysSwitch;
    JTMaterialSwitch *_aaSwitch;
}

- (void)viewDidLoad {
    
    [super viewDidLoad]; 
    [self switchView];
}
- (void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBarHidden=YES;
    [super viewWillAppear:animated];
}

//点击空白隐藏键盘
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    [self.view endEditing:YES];
}
//点击enter隐藏键盘
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [self.view endEditing:YES];
    return YES;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    //设置动画的名字
    [UIView beginAnimations:@"Animation" context:nil];
    //设置动画的间隔时间
    [UIView setAnimationDuration:0.20];
    //??使用当前正在运行的状态开始下一段动画
    [UIView setAnimationBeginsFromCurrentState: YES];
    //设置视图移动的位移
    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y - 100, self.view.frame.size.width, self.view.frame.size.height);
    //设置动画结束
    [UIView commitAnimations];
}
//在UITextField 编辑完成调用方法
- (void)textFieldDidEndEditing:(UITextField *)textField
{
    //设置动画的名字
    [UIView beginAnimations:@"Animation" context:nil];
    //设置动画的间隔时间
    [UIView setAnimationDuration:0.20];
    //??使用当前正在运行的状态开始下一段动画
    [UIView setAnimationBeginsFromCurrentState: YES];
    //设置视图移动的位移
    self.view.frame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + 100, self.view.frame.size.width, self.view.frame.size.height);
    //设置动画结束
    [UIView commitAnimations];
}
-(IBAction)next{
    RegisterController *l = [[RegisterController alloc] init];
    [self.navigationController pushViewController:l animated:YES];
}
#pragma mark-点击设置年龄按钮

-(void)switchView{
    _aaSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                style:JTMaterialSwitchStyleDefault
                                                state:JTMaterialSwitchStateOn];
    _aaSwitch.center = CGPointMake(kScreenWidth-40, 25);
    [_aaSwitch addTarget:self action:@selector(stateChanged) forControlEvents:UIControlEventValueChanged];
    [self.topView addSubview:_aaSwitch];
    
    _ysSwitch = [[JTMaterialSwitch alloc] initWithSize:JTMaterialSwitchSizeNormal
                                                 style:JTMaterialSwitchStyleDefault
                                                 state:JTMaterialSwitchStateOn];
    _ysSwitch.center = CGPointMake(kScreenWidth-40, 127);
    [_ysSwitch addTarget:self action:@selector(stateChanged) forControlEvents:UIControlEventValueChanged];
    [self.topView addSubview:_ysSwitch];
}
- (void)stateChanged
{
    if(_aaSwitch.isOn == YES) {
    }
    else {
    }
}
- (IBAction)tapHeatView:(id)sender {
    _buttonIndex = 3;
    HeatPickViewController *pickVC = [[HeatPickViewController alloc]init];
    [self addChildViewController:pickVC];
    pickVC.heatDataDelegate = self;
    pickVC.view.frame =CGRectMake(0, 0, kScreenWidth, kScreenHeight-64);
    [self.view addSubview:pickVC.view];
    
    
}
#pragma mark - 返回 代理
- (void)sendHeatData:(NSString * __nullable)heatData heatDataIndex:(NSString * __nullable)heatDataIndex{
        _twlable.text =heatData;
        _tw=heatDataIndex;
   
}//点击空白隐藏键盘
@end